package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.product.BaseTrademark;
import com.atguigu.gmall.product.service.BaseTrademarkService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: 🐱🐱🐱
 * @Date: 2025/8/18 20:50
 * @Description:
 **/
@Api("品牌列表")
@RestController
@RequestMapping("/admin/product/baseTrademark")
public class BaseTrademarkController {

    @Autowired
    private BaseTrademarkService baseTrademarkService;

    @ApiOperation(value = "分页列表")
    @GetMapping("{page}/{limit}")
    public Result index (@PathVariable Long page,
                         @PathVariable Long limit){
        Page<BaseTrademark> trademarkPage = new Page<>(page, limit);
       IPage<BaseTrademark> baseTrademarkList = baseTrademarkService.getPage(trademarkPage);
       return Result.ok(baseTrademarkList);
    }

    @ApiOperation("添加")
    @PostMapping("save")
    public Result save (@RequestBody BaseTrademark baseTrademark){
        baseTrademarkService.save(baseTrademark);
        return Result.ok();
    }

    @ApiOperation("获取BaseTrademark")
    @GetMapping("get/{id}")
    public Result get(@PathVariable String id){
       BaseTrademark baseTrademark = baseTrademarkService.get(id);
        return Result.ok(baseTrademark);
    }

    @ApiOperation("修改BaseTrademark")
    @PutMapping("update")
    public Result update(@RequestBody BaseTrademark baseTrademark){
        baseTrademarkService.updateById(baseTrademark);
        return Result.ok();
    }

    @ApiOperation("删除BaseTrademark")
    @DeleteMapping("remove/{id}")
    public Result remove(@PathVariable Long id){
        baseTrademarkService.removeById(id);
        return Result.ok();
    }


}
